
import std.c.stdlib:malloc;
import std.stdio:writefln;

struct TriTreeNode {
	TriTreeNode *leftChild;
	TriTreeNode *rightChild;
	TriTreeNode *baseNeighbor;
	TriTreeNode *leftNeighbor;
	TriTreeNode *rightNeighbor;
}

class TriPool{
	this(){
		triPool = cast(TriTreeNode*)malloc(poolSize * TriTreeNode.sizeof);
		nextTriNode = 0;
	}

	TriTreeNode* newTri(){
		TriTreeNode* tri;
	//	writefln(nextTriNode);
		assert(nextTriNode < poolSize);
		tri = &triPool[nextTriNode];
		tri.leftChild = tri.rightChild = null;
		nextTriNode++;
		return tri;
	}

	private{
		int				poolSize = 50000;
		TriTreeNode*	triPool;
	}
	public{
		int				nextTriNode;
	}
}
